/**
 * 选择辅助核算科目一
 *
 * */
import {useEffect, useState} from 'react';
import {CellInput} from '../components-v2';
import * as CommonDataSource from '../../../common-data-source';
export interface SelectAssistant1Props {
	// 用户选择的特别总账标识
	specialAccountFlag?: string,
	detailMode?: boolean,
	valueInLabel?: boolean,

}
export function SelectAssistant1(props: CellInput.ICellInputProps<string> & SelectAssistant1Props) {
	const {specialAccountFlag = "", value, disabled, onChange, detailMode = false, valueInLabel} = props;

	const [options, setOptions] = useState<Array<{name: string, value: string}>>([]);

	// useEffect(function () {
	// 	// http://jira.ecsphere.net:9080/browse/XYL-1423 辅助核算：不带特别总账标识条件
	// 	CommonDataSource.others.queryAssistantOptions()
	// 		.then(setOptions);
	// }, [specialAccountFlag]);

	if(detailMode) {
		const name = options.find((item) => item.value === value)?.name || '';
		return <span>{name}</span>
	}

	return (
			<CellInput.Selector style={{minWidth: '200px'}} valueInLabel={valueInLabel} dataSource={options} showSearch disabled={disabled} value={value} onChange={onChange}/>
	)
}
